package org.qqcui.designpattern.patterns.memorandum.game;


/**
 * 备忘录模式游戏客户端
 *
 * @author cuiqingqiang
 * @version 1.0
 * @date 2022/5/7 10:32
 **/
public class Client {

    public static void main(String[] args) {
        GameRole gameRole = new GameRole();
        gameRole.setVit(100);
        gameRole.setDef(80);

        System.out.println("大战Boss前的状态");
        gameRole.display();

        CareTaker careTaker = new CareTaker();
        careTaker.setMemento(gameRole.createMemento());

        gameRole.setDef(30);
        gameRole.setVit(40);
        System.out.println("大战后的状态");
        gameRole.display();
        System.out.println("恢复大战前的状态");
        gameRole.recoverFromMemento(careTaker.getMemento());
        gameRole.display();
    }
}
